home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2140 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.2 KB  |  43 lines

  1. Path: newsserver.trl.OZ.AU!usenet
  2. From: t.hand@trl.oz.au (Trevor Hand)
  3. Newsgroups: comp.lang.c++
  4. Subject: BC45, using a function in another project.
  5. Date: 16 Jan 1996 04:36:22 GMT
  6. Organization: Telstra Research Laboratories
  7. Message-ID: <4dfa06$eui@newsserver.trl.OZ.AU>
  8. NNTP-Posting-Host: tmp_ip_159.trl.oz.au
  9. X-Newsreader: News Xpress Version 1.0 Beta #3
  10.  
  11. I am building a group of general functions which are
  12. stored in a file called "MyUtils\GenUtil.cpp".  How do I
  13. declare each function so that they are available to another
  14. file in another directory, ie. they have global access, so
  15. they can be used by other projects. eg.
  16.  
  17. ------------------------------
  18. \MyUtils\GenUtil.cpp -
  19. my collection of functions
  20.  
  21. int MyGeneralVariable;
  22.  
  23. void MyGeneralFunction(){
  24.   //Does something usefull
  25.   };
  26. ------------------------------
  27.  
  28. ------------------------------
  29. \Programs\MyApp.cpp
  30. #include "GenUtil.h" //I have set Project/Options to include a
  31. //path to MyUtils.  A node to GenUtil.cpp is added to the IDE file.
  32. :
  33. :
  34. MyGeneralFunction();//Linker says MyGeneralFunction is undefined
  35. i = MyGeneralVariable;//I also want to use a variable from GenUtil.
  36. :
  37. ------------------------------
  38.  
  39. What do I have to do?  Does MyGeneralFunction() have to be extern?
  40.  
  41. Trevor Hand
  42. t.hand@trl.oz.au
  43.